

module.exports =require('./fsmmanager.js');

//notes:
/*
case 1: 
	Event is from Stack1 to subscriber1 - Stack1
	
			incoming event from stack:		
				header.eventkey = xxx
				header.eventname = xxx
				header.eventtype = REQUEST
				header.respeventname = xxx
				
			outgoing event to same stack:
				header.eventkey = get(eventkey)		header.eventname = get(respeventname)
				header.eventname = get(respEventName)
				header.eventtype = RESPONSE
				header.respeventname = null		
	
	Event is from Stack1 to subscriber1 - Stack2
	
			outgoing event to stack2
				header.eventkey = xxx
				header.eventname = xxx
				header.eventtype = REQEUST
				header.respeventname = null		
		
	
case 2:
	Event is form Stack1 to Subscriber1 - suscriber2 - Subscriber1 - stack1
	
			outgoing event to subscriber2 from subscriber1
				header.eventkey = xxx
				header.eventname = xxx
				header.eventtype = REQEUST
				header.respeventname = xxx		
	
			outgoing event to subscriber1 from subscriber2
				header.eventkey = get(eventkey)
				header.eventname = get(respEventName)
				header.eventtype = RESPONSE
				header.respeventname = null	

case 3:
	Event is from Stack1 to Subscriber1-Fsm1 to fsm2 to dbstack to fsm2 to fsm1 to stack1 
	
	
	from stack1:		
				header.eventkey = 1000
				header.eventname = 1000_eventname
				header.eventtype = REQUEST
				header.respeventname = 1000_respeventname
				
	fsm1 to fsm2
				header.eventkey = 2000
				header.eventname = 2000_eventname
				header.eventtype = REQUEST
				header.respeventname = 2000_respeventname
	
	fsm2 to dbstack
				header.eventkey = 3000
				header.eventname = 3000_eventname
				header.eventtype = REQUEST
				header.respeventname = 3000_respeventname
	dbstack to fsm2
				header.eventkey = 3000
				header.eventname = 3000_respeventname
				header.eventtype = RESPONSE
				header.respeventname = null
	fsm2 to fsm1
				header.eventkey = 2000
				header.eventname = 2000_respeventname
				header.eventtype = RESPONSE
				header.respeventname = null
	
	
	to stack1:
				header.eventkey = 1000
				header.eventname = 1000_respeventname
				header.eventtype = RESPONSE
				header.respeventname = null	
	
	
	
	
	
	::sending internal event
		var payload = {'message':'SOME REQUEST'};
		var eventObj = pFsmSession.createNewEvent('SUBSCRIBERAPP.TEST.REQUEST', 'REQUEST', payload);
		eventObj.setRespEventName('SUBSCRIBERAPP.TCP.EVENT1');
		pFsmSession.sendEvent (eventObj, 'state_WaitingFsmResp');
		
		
	::sending response event for both internal and external
	
		var payload = {'message':'SOME RESPONSE'};
					
		var eventObj = pFsmSession.createNewEvent(pFsmSession.rcvdEvent.getRespEventName(), 'RESPONSE');				
		eventObj.setEventKey(pFsmSession.rcvdEvent.getEventKey());
		eventObj.setPayload(payload);
		
		or
		
		var eventObj = pFsmSession.createRespEvent(payload, pFsmSession.rcvdEvent);
		pFsmSession.sendEvent (eventObj, 'state_exit');
	
		or
		
		var eventObj = pFsmSession.createRespEvent(payload);								
		pFsmSession.sendEvent (eventObj, 'state_exit');
*/